<?php
namespace Home\Controller;

class UserPageController extends ParentController {
    protected function _initialize() {
        $hotelId = I('get.hotel');
        $this->checkLanguage();
        $this->assignHotelDefultCurrency($hotelId);
        if (empty(parent::isLogin())) {
            redirect('/Home/PublicPage/login?hotel='.$hotelId);
        }

    }

    public function index() {
        $hotelId = I('get.hotel');
        $this->assign('hotelId', $hotelId);
        $areaCode = session(C('USER_AREACODE'));
        $mobile = session(C('USER_MOBILE'));
        $vipUserModel = D('VipUser');
        $vipUserInfo = $vipUserModel->getInfoByMobile($hotelId, $mobile);
        $vipInfoModel = D('VipInfo');
        $vipInfo = $vipInfoModel->getInfoById($vipUserInfo['vipinfo_id']);
        $this->assign('name', session(C('USER_NAME')));
        $this->assign('areaCode', $areaCode);
        $this->assign('mobile', $mobile);
        $this->assign('level', $vipInfo['name']);
        $this->display();
    }

    public function logout() {
        parent::logout();
        $hotelId = I('get.hotel');
        redirect('/Home/PublicPage/login?hotel='.$hotelId);
    }
}
